package com.cskaoyan.javase.oop3._1interface._3exercise;

/**
 * 教练（Coach）和运动员（Sportsman）案例
 * 小试牛刀请用所学知识分析：这个案例中有哪些抽象类，哪些接口，哪些具体类。
 * 现在有乒乓球运动员和篮球运动员，乒乓球教练和篮球教练。
 * 为了能学够出国交流，跟乒乓球相关的人员都需要习英语。
 *
 * 普通类: 乒乓球运动员和篮球运动员，乒乓球教练和篮球教练,都需要定义相应的类型
 * 抽象类: 抽象的运动员类,抽象的教练类
 * 接口: 扩展学英语的功能
 *
 *
 * @since 17:18
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        AbstractSportsman as = new TableTennisSportsman("张三", 8, 1000, 3);
        System.out.println(as.name);
        as.exercise();
        ((TableTennisSportsman) as).learn();
        ILearningEnglish ie = new TableTennisSportsman("张三", 8, 1000, 3);
    }
}

// 抽象的运动员类
abstract class AbstractSportsman {
    String name;
    int age;
    double salary;
    int serviceYears;

    public AbstractSportsman(String name, int age, double salary, int serviceYears) {
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.serviceYears = serviceYears;
    }

    public abstract void exercise();
}

// 抽象的教练类
abstract class AbstractCoach {
    String name;
    int age;
    double salary;
    int teachYears;

    public AbstractCoach(String name, int age, double salary, int teachYears) {
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.teachYears = teachYears;
    }

    public abstract void teach();
}

interface ILearningEnglish {
    void learn();
}

// 定义具体类
class TableTennisSportsman extends AbstractSportsman implements ILearningEnglish {

    public TableTennisSportsman(String name, int age, double salary, int serviceYears) {
        super(name, age, salary, serviceYears);
    }
    @Override
    public void exercise() {
        System.out.println("我每天打乒乓球,训练十二个小时~");
    }

    @Override
    public void learn() {
        System.out.println("在宾馆里租个房间学英语~~");
    }
}

class BasketballCoach extends AbstractCoach {
    public BasketballCoach(String name, int age, double salary, int teachYears) {
        super(name, age, salary, teachYears);
    }

    @Override
    public void teach() {
        System.out.println("我教你⛹~~");
    }
}